/******************************************************************************
 *  Author:     Williams, Jacob (williamsj@msoe.edu)
 *  Class:      CE-3910
 *  Instructor: Dr. Barnekow
 *****************************************************************************/
#ifndef CAMERA_H_
#define CAMERA_H_

#include "twi.h"
#include <stdbool.h>
#include <stdint.h>

/**
 * This function initializes the camera system so that images can be pulled from it to allow tracking
 * This functon sets PORTA as input as well as Pins 6, 3 and 2 on PORTD
 * This function also calls for the TWI subsystem to initialize
 */
void init(void);

/**
 * This function calibrates one of the colors used by the camera to determine
 * if a pixel is white or black. The single parameter is used to determine
 * which color is being set. This function works by looking for the highest
 * value and the lowest value and averaging them. This means that a solid white
 * or black image needs to be presented to calibrate.
 * @param calWhite  If calibrating for white this is true. If false black will
 *                  be calibrated instead.
 */
void calibrate(bool calWhite);

/**
 * Getter for the white color
 * @return The current color for white
 */
uint8_t getWhite(void);

/**
 * Getter for the black color
 * @return The current color for black
 */
uint8_t getBlack(void);

/**
 * Getter for the current threshold
 * @return The current threshold
 */
uint8_t getThresh(void);

/**
 * Processes the next frame for tracking. Determines the location of the object
 * by looking at the first line which a white pixel appears for the x location
 * recording the first and last y value a white pixel appears on. This method
 * sets objectXCenter and objectYCenter rather than having a return
 */
void processImage(void);

/**
 * Getter for the objects center's x-location
 * @return The X location of the object's center
 */
uint8_t getObjectXCenter(void);

/**
 * Getter for the object's center's y-location
 * @return The Y location of the object's center
 */
uint8_t getObjectYCenter(void);

#endif /* CAMERA_H_ */
